﻿@using ZoomLa.Common
@using ZoomLa.BLL
@using ZoomLa.Model
@using System.Data
@using ZoomLaCMS.Models.Field
@using ZoomLa.AppCode.Controls
@using ZoomLa.Components
@model ZoomLaCMS.Models.Content.VM_Content
@functions { 
    B_Group gpBll = new B_Group();
    public string GetFieldAlias(string field)
    {
        return B_Content.GetFieldAlias(field,Model.fieldDT);
    }
}
@{
    B_Spec spbll = new B_Spec();
    DataTable ddlDT = ViewBag.ddlDT as DataTable;
    DataTable gpDT = gpBll.Sel();
    string action = Model.conMod.GeneralID > 0 ? "修改" : "添加";
    string basePath = CustomerPageAction.customPath2 + "Content/";
}
@section head{
<title>@(action+Model.modelMod.ItemName)</title>
<script charset="utf-8" src="/Plugins/Ueditor/ueditor.config.js"></script>
<script charset="utf-8" src="/Plugins/Ueditor/ueditor.all.js"></script> 
<style type="text/css">
.excontent_wrap{display:inline-block;width:120px;margin-top:5px;margin-left:5px;}
.excontent_wrap .verbak_l{font-weight:normal;position:relative;top:3px;}
</style>      
}
@section content{
<div id="BreadDiv" class="container-fluid mysite">
    <div class="row">
        <ol id="BreadNav" class="breadcrumb navbar-fixed-top">
            <li><a href="@(CustomerPageAction.customPath2)I/Main.aspx">工作台</a></li>
            <li><a href="@(basePath)ContentManage.aspx">内容管理</a></li>
            <li><a href="@(basePath)ContentManage.aspx?NodeID=@Model.NodeID">@Model.nodeMod.NodeName</a></li>
            <li class="active">
                [向本栏目添加@(Model.modelMod.ItemName)]
                @if (!string.IsNullOrEmpty(Model.conMod.Template))
                {
                    <span style="color:red;">(该内容已启用个性模板)</span>
                }
            </li>
            <div class="pull-right hidden-xs">
                <span>
                    <a href="@(basePath)SchedTask.aspx" title="查看计划任务"><span class="fa fa-clock-o" style="color:#28b462;"></span></a>
                    <a href="/Class_@Model.NodeID/Default.aspx" target="_blank" title="前台浏览"><span class="fa fa-eye"></span></a>
                    <span onclick="ShowDiag('@(basePath)Node/EditNode.aspx?NodeID=@Model.NodeID','配置本节点');" class="fa fa-cog" title="配置本节点" style="cursor:pointer;margin-left:5px;">
                    </span>
                </span>
            </div>
        </ol>
    </div>
</div>
<form method="post" id="form1">
    <div class="manage_content">
        <div class="tabbable">
            <ul class="nav nav-tabs">
                <li class="active"><a href="#ConInfo" data-toggle="tab">内容信息</a></li>
                <li><a href="#InfoAttr" data-toggle="tab">信息属性</a></li>
                <li><a href="#Process " data-toggle="tab">流程控制</a></li>
                <li><a href="#Copyright " data-toggle="tab">版权管理</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="ConInfo">
                    <table id="mainTable" class="table table-bordered table_padding0 addcontent_modeltale">
                        <tr>
                            <td style="overflow-x: hidden;" class="col-sm-1 col-xs-1 fd_td_l">
                                @GetFieldAlias("Title")：
                            </td>
                            <td class="col-sm-11 col-xs-11">
                                <input type="text" id="txtTitle" name="txtTitle" Style="background: url(/Images/bg1.gif) repeat-x;" class="form-control m715-50 required" onkeyup="Getpy('txtTitle','PYtitle')" value="@Model.conMod.Title" />
                                <span class="vaild_tip">*</span>
                                <button type="button" class="btn btn-info btn-sm" onclick="ShowTitle()"><i class="fa fa-info"></i>标题属性</button>
                                <button type="button" class="btn btn-info btn-sm" onclick="ShowSys();"><i class="fa fa-list"></i></button>
                                <input type="hidden" id="ThreadStyle" name="" value="@Model.conMod.TitleStyle" />
                                <div id="duptitle_div" class="alert alert-warning" style="position: absolute; margin-left: 315px; display: none;">
                                    <ul id='duptitle_ul'></ul>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-right">内容功能：</td>
                            <td>
                                <div class="input-group excontent_wrap">
                                    <span class="input-group-addon" style="padding:4px 10px;"><label class="verbak_l"><input type="checkbox" name="verbak_chk" value="1" /> 存档备份</label></span>
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-info btn-sm" @(Model.conMod.GeneralID < 1 ? "disabled=\"disabled\"" : "") onclick="conhelp.verbak.showDiag();"><i class="fa fa-database"></i> 版本浏览</button>
                                        <button type="button" class="btn btn-info btn-sm" onclick="ShowContentList()"><i class="fa fa-chain"></i> 关联内容</button>
                                    </span>
                                </div>
                            </td>
                        </tr>
                        <tbody id="Sys_Fied" style="display:@(Model.nodeMod.Contribute==1?"none":"")">
                            <tr>
                                <td class="fd_td_l"><span>拼音缩写：</span></td>
                                <td>
                                    @Html.TextBox("PYtitle", Model.conMod.PYtitle, new { @class = "form-control m715-50" })
                                </td>
                            </tr>
                            <tr id="spec_tr">
                                <td class="fd_td_l"><span>所属专题：</span></td>
                                <td>
                                    <div class="specDiv">
                                        @foreach (DataRow dr in Model.SpecialDT.Rows)
                                        {
                                            <div class='spec'><div class='specname'>@dr["SpecName"]</div> <a href='javascript:;' onclick='removeSpe(this,"@dr["SpecID"]")'><span class='fa fa-remove'></span></a></div>
                                        }
                                    </div>
                                    <span id="specbtn_span">
                                        @if (spbll.GetFirstID() > 0)
                                        {<button type='button' class='btn btn-info btn-sm' onclick='ShowSpecDiag()'>添加至专题</button> }
                                        else
                                        { <div style='margin:5px;' class='btn btn-default disabled'><span class='fa fa-info-circle'></span> 尚未定义专题</div>}
                                    </span>
                                    @Html.Hidden("Spec_Hid", Model.conMod.SpecialID)
                                </td>
                            </tr>
                            <tr>
                                <td class="fd_td_l">@GetFieldAlias("TagKey")：</td>
                                <td>
                                    <div id="OAkeyword"></div>
                                    <input type="text" id="Keywords" name="Keywords" value="@Model.conMod.TagKey" class="form-control" />
                                    <span>(空格或回车键分隔，长度不超过10字符或5汉字)</span>
                                </td>
                            </tr>
                            <tr>
                                <td class="fd_td_l">@GetFieldAlias("Subtitle")：</td>
                                <td>
                                    @Html.TextBox("Subtitle", Model.conMod.Subtitle, new { @class = "form-control m715-50" })
                                </td>
                            </tr>
                        </tbody>
                        @Html.Partial("Fields/Index_Admin_AddContent", new VM_FieldModel(Model.ModelID, Model.NodeID, new ModelConfig() { Source = ModelConfig.SType.Admin }, Model.conMod.GeneralID,Model.ValueDR))
                        <tr id="attPic">
                            <td class="fd_td_l">主编辑器扩展图：</td>
                            <td style="height: 80px;">
                                <ul id="ThumImg_ul" class="preview_img_ul"></ul>
                                <div class="clearfix"></div>
                                @Html.Hidden("ThumImg_Hid", Model.conMod.TopImg)
                            </td>
                        </tr>
                        @if (Model.nodeMod.ListPageHtmlEx < 3)
                        {
                            <tr>
                                <td class="fd_td_l">生成@(Model.modelMod.ItemName)</td>
                                <td>
                                    <label>@(Html.CheckBox("quickmake", false))是否立即生成</label>
                                </td>
                            </tr>
                        }
                    </table>
                    <div style="height: 50px;"></div>
                </div>
                <div class="tab-pane fade" id="InfoAttr">
                    <table class="table table-bordered table_padding0">
                        <tr>
                            <td class="fd_td_l td_l">录入者</td>
                            <td>
                                @Html.TextBox("Inputer", Model.conMod.Inputer, new { @class = "form-control text_md", disabled = "disabled" })
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">添加时间</td>
                            <td>
                                @Html.TextBox("CreateTime", Model.conMod.CreateTime, new { @class = "form-control text_md", onclick = "WdatePicker({ dateFmt: 'yyyy/MM/dd HH:mm:ss' })" })
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">
                               @GetFieldAlias("UpDateTime")
                            </td>
                            <td>
                                @Html.TextBox("UpDateTime", Model.conMod.UpDateTime, new { @class = "form-control text_md", onclick = "WdatePicker({ dateFmt: 'yyyy/MM/dd HH:mm:ss' })" })
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">自动审核</td>
                            <td>
                                <input type="text" id="ExamineTime" name="ExamineTime" class="form-control text_md" value="@Model.ExamineTime" onclick="WdatePicker({ dateFmt: 'yyyy/MM/dd HH:mm:ss', minDate:'@DateTime.Now'})" />
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">自动过期</td>
                            <td>
                                <input type="text" id="ExpiredTime" name="ExpiredTime" class="form-control text_md" value="@Model.ExpiredTime" onclick="WdatePicker({ dateFmt: 'yyyy/MM/dd HH:mm:ss', minDate: '#F{$dp.$D(\'ExamineTime\')}' })" />
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">
                                @GetFieldAlias("Hits")
                            </td>
                            <td>
                                @Html.TextBox("Hits", Model.conMod.Hits, new { @class = "form-control text_md" })
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">访问权限</td>
                            <td>
                                @MVCHelper.H_Checks("UGroupAuth",gpDT,"GroupID","GroupName",Model.conMod.UGroupAuth)
                                <span class="rd_green">
                                    (不勾选则为不限制)
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">允许评论</td>
                            <td>
                                @MVCHelper.H_Radios("IsComm_Radio", "是,否".Split(','), "1,0".Split(','), Model.conMod.IsComm.ToString())
                                <span class="rd_green">(该操作只在节点管理下配置了允许发表评论时生效!)</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l">个性模板</td>
                            <td>
                                @MvcHtmlString.Create(PageCommon.GetTlpDP("TemplateUrl"))
                                <input type="hidden" id="TemplateUrl_hid" name="TemplateUrl_hid" value="@Model.conMod.Template" />
                            </td>
                        </tr>
                        @if (Model.conMod.GeneralID > 0)
                        {
                            <tr>
                                <td class="fd_td_l">PDF文件</td>
                                <td>
                                    <div class="input-group" style="width:508px;">
                                        <input type="text" class="form-control text_300" id="content_pdf_t" value="@Model.conMod.PdfLink" placeholder="尚未生成" />
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn-info" onclick="conhelp.pdf.create(this);"><i class="fa fa-file"></i> 生成</button>
                                            @*<button type="button" class="btn btn-info" onclick="conhelp.pdf.view();"><i class="fa fa-eye"></i> 预览</button>*@
                                            <button type="button" class="btn btn-info" onclick="conhelp.pdf.down();"><i class="fa fa-download"></i> 下载</button>
                                            <button type="button" class="btn btn-danger" onclick="conhelp.pdf.del();"><i class="fa fa-trash-o"></i> 删除</button>
                                        </span>
                                    </div>
                                </td>
                            </tr>
                            <tr><td class="fd_td_l">Word文件</td><td>
                                    <div class="input-group" style="width:508px;">
                                        <input type="text" class="form-control text_300" id="content_word_t" value="@Model.conMod.Rtype" placeholder="尚未生成" />
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn-info" onclick="conhelp.word.create(this); disBtn(this, 2000);"><i class="fa fa-file"></i> 生成</button>
                                            @*<button type="button" class="btn btn-info" onclick="conhelp.pdf.view();"><i class="fa fa-eye"></i> 预览</button>*@
                                            <button type="button" class="btn btn-info" onclick="conhelp.word.down();"><i class="fa fa-download"></i> 下载</button>
                                            <button type="button" class="btn btn-danger" onclick="conhelp.word.del();"><i class="fa fa-trash-o"></i> 删除</button>
                                        </span>
                                    </div>
                                </td></tr>
                        }
                    </table>
                    @*<ZL:TlpListView ID="TlpView_Tlp" IsFirstSelect="False" TemplateTitle="name" runat="server" />*@
                </div>
                <div class="tab-pane fade" id="Process">
                    <table class="table table-bordered">
                        <tr>
                            <td class="fd_td_l td_l">
                                <label>@GetFieldAlias("EliteLevel")</label>
                            </td>
                            <td>
                                @MVCHelper.H_Check("EliteLevel", "推荐", "1", Model.conMod.EliteLevel.ToString())
                            </td>
                        </tr>
                        <tr>
                            <td class="fd_td_l"><label>@GetFieldAlias("Status")</label></td>
                            <td>
                                @MVCHelper.H_Radios("ddlFlow", ddlDT, "PPassCode", "PName", Model.conMod.Status.ToString())
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="tab-pane fade" id="Copyright">
                    @if (Model.conMod.GeneralID < 1)
                    {
                        <div class="alert alert-info">
                            <span><strong>提示：</strong></span>
                            未识别到文章ID,请保存后重编辑设定。
                        </div>
                    }
                    else
                    {
                        <table class="table table-bordered">
                            <tr>
                                <td id="middle_td" class="fd_td_l td_l">授权规则</td>
                                <td>
                                    <div class="form-group text_300">
                                        <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
                                        <div class="input-group">
                                            <div class="input-group-addon">转载使用</div>
                                            <input type="text" class="form-control text-right" id="RepPri_T" placeholder="0-99元的整数">
                                            <div class="input-group-addon">.00</div>
                                        </div>
                                    </div>
                                    <div class="form-group text_300 bottom0">
                                        <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
                                        <div class="input-group">
                                            <div class="input-group-addon">素材使用</div>
                                            <input type="text" class="form-control text-right" id="MatPri_T" placeholder="0-99元的整数">
                                            <div class="input-group-addon">.00</div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr id="worksid_tr" class="hide">
                                <td class="fd_td_l">版权编号</td>
                                <td>
                                    <label id="cr_worksid_l"></label>
                                </td>
                            </tr>
                            <tr id="workslink_tr" class="hide">
                                <td class="fd_td_l">售卖网址</td>
                                <td id="cr_worklink"></td>
                            </tr>
                            <tr>
                                <td class="fd_td_l">授权操作</td>
                                <td>
                                    <a href="javascript:void(0);" onclick="crhelper.add()" id="cradd_a" class="btn btn-primary disabled"><i class="fa fa-plus"></i>添加授权</a>
                                    <a href="javascript:void(0);" onclick="crhelper.del()" id="crdel_a" class="btn btn-danger disabled"><i class="fa fa-trash"></i>暂停授权</a>
                                    <a href="javascript:void(0);" onclick="crhelper.readd()" id="crreadd_a" class="btn btn-info disabled"><i class="fa fa-refresh"></i>重新授权</a>
                                </td>
                            </tr>
                        </table>
                        <div id="configcr" class="alert alert-info" style="display: none;">
                            <span><strong>提示：</strong></span>未配置版权印接口，若要使用版权功能，请 <a class="btn btn-info" href="../Config/PlatInfoList.aspx">前往配置>></a>
                        </div>
                    }
                </div>
            </div>
        </div>
        <div class="Conent_fix">
            @Html.Hidden("RelatedIDS_Hid", Model.conMod.RelatedIDS)
            @if (Model.conMod.GeneralID < 1)
            {
                <input type="button" value="@(action+ Model.modelMod.ItemName)" onclick="subform('@MVCHelper.GetAction("Content_Add",Request)');" class="btn btn-primary" />
                <input type="button" value="存为草稿" onclick="subform('@MVCHelper.GetAction("Content_Draft",Request)');" class="btn btn-primary" />
            }
            else
            {
                <input type="button" value="@(action+ Model.modelMod.ItemName)" onclick="subform('@MVCHelper.GetAction("Content_Update",Request)');" class="btn btn-primary" />
                <input type="button" value="添加为新@(Model.modelMod.ItemName)" onclick="subform('@MVCHelper.GetAction("Content_AddToNew",Request)');" class="btn btn-primary" />
            }
            <a href="@(basePath+"ContentManage.aspx?NodeID="+Model.NodeID)" class="btn btn-primary">返回列表</a>
            <a href="javascript:;" id="toTop" onclick="Control.Scroll.ToTop();"><i class="fa fa-upload"></i>Top</a>
        </div>
        <div id="pushcon_div" class="alert alert-info">
            <div>保存时自动推送<a href="javascript:$('#pushcon_div').hide();;" title="隐藏"><span class="fa fa-remove"></span></a></div>
            <ul id="pushcon_ul" class="list-unstyled"></ul>
            @Html.Hidden("pushcon_hid")
        </div>
        @Html.Partial("C_TlpDP", new C_TlpDP("TemplateIndex", ""))
    </div>
</form>    
}
@section script{
<script>
    var zlconfig = {
        adminPath:"@CustomerPageAction.customPath2",
        updir: "@ZoomLa.Components.SiteConfig.SiteOption.UploadDir.ToLower()",
        duptitlenum: "@ZoomLa.Components.SiteConfig.SiteOption.DupTitleNum",
        modelid: "@Model.ModelID",
        keys: "@Request["keys"]",
        gid: "@Model.conMod.GeneralID"
    };
</script>
<script src="/JS/OAKeyWord.js"></script>
<script src="/JS/DatePicker/WdatePicker.js"></script>
<script src="/JS/chinese.js"></script>
<script src="/JS/Common.js"></script>
<script src="/JS/Controls/ZL_Dialog.js"></script>
<script src="/JS/Controls/Control.js"></script>
<script src="/JS/ICMS/tags.json"></script>
<script src="/JS/ZL_Content.js?v=@(ZoomLa.BLL.BLLCommon.Version_JS)"></script>
<script src="/JS/Modal/APIResult.js"></script>
<script src="/JS/ZL_Regex.js"></script>
<script>
    $(function () {
        Tlp_initTemp();
        crhelper.init();
        ZL_Regex.B_Num("#RepPri_T,#MatPri_T");
        ZL_Regex.B_Value("#RepPri_T,#MatPri_T", { min: 0, max: 99, overmin: function () { }, overmax: function () { } });
        $("form").validate();
        @*if ("@Model.nodeMod.Contribute" == "1") { ShowSys(); }*@
    });
    function subform(url) {
        var vaild = $("form").validate({ meta: "validate" });
        if (!vaild.form()) { return false; }
        else { mvcpage.help.submit({ "url": url }); }
    }
    //智能模板选择事件
    function OnTemplateViewCheck(value) {
        $("#TemplateUrl_hid").val(value);
    }
    function ShowContentList() {//关联内容
        var url = $("#RelatedIDS_Hid").val() != "" ? "?ids=" + $("#RelatedIDS_Hid").val() : "";
        ShowDiag("@(basePath)SelContentTitle.aspx" + url, "选择关联内容");
    }
    //版权印
    var crhelper = { api: "/manage/Copyright/cr.ashx", gid:"@Model.conMod.GeneralID" };
    crhelper.init = function () {
        try {
            $.post(this.api + "?action=get", { gid: crhelper.gid }, function (data) {
                var model = APIResult.getModel(data);
                if (APIResult.isok(model)) {
                    $("#workslink_tr,#worksid_tr").removeClass("hide");
                    $("#RepPri_T").val(model.result.RepPrice);
                    $("#MatPri_T").val(model.result.MatPrice);
                    $("#cr_worksid_l").text(model.result.WorksID);
                    var link = "http://www.banquanyin.com/" + model.result.WorksID;
                    $("#cr_worklink").text("").append($("<a href='" + link + "' target='_blank' >" + link + "</a>"));
                    $("#cradd_a").addClass("disabled");
                    $("#crdel_a").removeClass("disabled");
                    $("#crreadd_a").removeClass("disabled");
                }
                else {
                    $("#RepPri_T,#MatPri_T").val("");
                    $("#workslink_tr,#worksid_tr").addClass("hide");
                    $("#cradd_a").removeClass("disabled");
                    $("#crdel_a").addClass("disabled");
                    $("#crreadd_a").addClass("disabled");
                    if (model.retmsg == "未配置版权印接口") {
                        $("#cradd_a").addClass("disabled");
                        $("#configcr").css("display", "block");
                    }
                }
            });
        } catch (ex) { console.log("copyright:" + ex.message); }
    }
    crhelper.add = function(){
        var repprice = $("#RepPri_T").val();
        var matprice = $("#MatPri_T").val();
        $.post(this.api+"?action=add",{ gid: crhelper.gid, repprice: repprice, matprice: matprice },function(data){
            var model = APIResult.getModel(data);
            if(APIResult.isok(model)){
                crhelper.init();
                alert("添加成功，版权编号为:"+model.result);
            }else{ alert("操作失败:"+model.retmsg); }
        });
    }
    crhelper.del = function(){
        if(!confirm("确定要暂停授权吗")){return;}
        $.post(this.api+"?action=del",{ gid: crhelper.gid },function(data){
            var model = APIResult.getModel(data);
            if(APIResult.isok(model)){
                crhelper.init();
                alert("操作成功!");
            }else{ alert("操作失败:"+model.retmsg); }
        });
    }
    crhelper.readd = function(){
        var repprice = $("#RepPri_T").val();
        var matprice = $("#MatPri_T").val();
        var worksid = "";
        $.post(this.api+"?action=readd",{ gid:crhelper.gid, repprice: repprice, matprice: matprice },function(data){
            var model = APIResult.getModel(data);
            if(APIResult.isok(model)){
                crhelper.init();
                alert("操作成功!新的版权编号为:"+model.result);
            }else{ alert("操作失败:"+model.retmsg); }
        });
    }
    function ShowSpecDiag() {
        ShowDiag("/@SiteConfig.SiteOption.ManageDir/Content/SpecialList.aspx", "选择专题 [<a href='javascript:;' onclick='SelSpec()'>选好点此确认</a>]");
    }
</script>    
}